﻿<!DOCTYPE html>
<html>

<head>

    {include file="Public/header"}
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
      <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/sc/js/page.js"></script>
    <style>
        .textMax {
            min-width: 60px;
            max-width: 120px;
        }
    </style>
</head>

<body style="color:#333;padding:3px;">
<!-- 标题 -->
<div class="page-heade">
    <h2 class="title_color text-center">经销商合同管理</h2>
</div>
<!-- 标题 -->
<div class="form-inline">
    <form action="#" id="f1" method="post" class="formpage">
      <input type="hidden" value='{$page}' name="page" id="page-go"/>
                      <input type="hidden" value='{$list}' name="list" id="list-go"/>
        <table class="row-margin-top tab-content table-bordered table" border="1">
           
            <tr>
                <td class="text-right" style="min-width: 120px;width: 120px"><label for=""class="form-label">签署时间</label></td>
                <td>
                    <div class="form-group">
                        <input type="text" id="start" class="form-control layer-date "
                               style="width:100px;display: inline-block;" name="start" value="{$data.start}">
                    </div>
                    <div class="form-group">
                        至
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control layer-date" style="width:100px;display: inline-block;"
                               id="end" name="end" value="{$data.end}">
                    </div>
                </td>
                <td class="text-right" style="min-width: 100px;width: 100px"><label for="">分区</label></td>
                <td><input type="text" class="form-control textMax" name="fenqu" value="{$data.fenqu}"></td>
                <td class="text-right" style="min-width: 100px;width: 100px"><label for="">省份</label></td>
                <td><input type="text" class="form-control textMax" name="sheng" value="{$data.sheng}"></td>
                <td class="text-right" style="min-width: 100px;width: 100px"><label for="">城市</label></td>
                <td><input type="text" class="form-control textMax" name="shi" value="{$data.shi}"></td>
            </tr>
            <tr>
                <td class="text-right" style="min-width: 120px;width: 120px"><label for="" class="form-label">合同费用率</label>
                </td>
                <td>
                    <input type="text" class="form-control num" style="width:100px;" name="feilvdi" value="{$data.feilvdi}">%至
                    <input type="text" class="form-control num" style="width:100px;" name="feilvgao" value="{$data.feilvgao}">%
                </td>
                <td class="text-right" style="min-width: 100px;width: 100px"><label for="" class="form-label">经销商</label></td>
                <td><input type="text" class="form-control textMax" name="jxs_name" value="{$data.jxs_name}"></td>
                <td class="text-right" style="min-width: 100px;width: 100px"><label for="" class="form-label">合同编号</label></td>
                <td><input type="text" class="form-control textMax" name="htbh" value="{$data.htbh}"></td>
                <td class="text-right" style="min-width: 100px;width: 100px"><label for="" class="form-label">合同名称</label></td>
                <td><input type="text" class="form-control textMax" name="htmc" value="{$data.htmc}"></td>
            </tr>
            <tr>
                <td class="text-right" style="min-width: 160px;width: 160px"><label for="" class="form-label">合同有效期：</label>
                </td>
                <td>
                    <div class="form-group">
                        <input type="text" id="start1" class="form-control layer-date "
                               style="width:100px;display: inline-block;" name="start1" value="{$data.start1}">
                    </div>
                    <div class="form-group">
                        至
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control layer-date" style="width:100px;display: inline-block;"
                               id="end1" name="end1" value="{$data.end1}">
                    </div>
                </td>
                <td class="text-right" style="min-width: 100px;width: 100px"><label for="" class="form-label">授权品牌</label></td>
                <td><input type="text" class="form-control textMax" name="pp" value="{$data.pp}"></td>
                <td class="text-right" style="min-width: 100px;width: 100px"><label for="">授权品类</label></td>
                <td><input type="text" class="form-control textMax" name="pl" value="{$data.pl}"></td>
                <td class="text-right" style="min-width: 100px;width: 100px"><label for="">授权系统</label></td>
                <td><input type="text" class="form-control textMax" name="sqxt" value="{$data.sqxt}"></td>
            </tr>
            <tr>
                <td class="text-right" style="min-width: 120px;width: 120px"><label for="" class="form-label">合同销售目标</label>
                </td>
                <td>
                    <input type="text" class="form-control num" style="width:100px;" name="tardi" value="{$data.tardi}">至
                    <input type="text" class="form-control num" style="width:100px;" name="targao" value="{$data.targao}">
                </td>
                <td class="text-right" style="min-width: 120px;width: 100px"><label for="" class="form-label">合同状态</label></td>
                <td>
                    <select name="st" id="" class="form-control">
                        <option value="0">请选择</option>
                        {volist name="state" id="s"}
                            {if $s.id==$data.st}
                            <option value="{$s.id}" selected>{$s.title}</option>
                            {else/}
                            <option value="{$s.id}">{$s.title}</option>
                            {/if}
                        {/volist}
                    </select>
                </td>
                <td class="text-right" style="min-width: 100px;width: 100px"><label for="">申请人：</label></td>
                <td><input type="text" class="form-control textMax" name="em_name" value="{$data.em_name}"></td>
                <td colspan="2" class="text-center">
                    <button class="btn btn-info query" type="button" id="check">查询</button>
                    <button class="btn btn-info emptyIf" type="button" id="clear_check">清空查询条件</button>
                </td>
            </tr>
        </table>

        <table class="table row-margin-top table-bordered table-hover text-center bud_hei">
            <tr class="info text-center">
                <th class="text-center">NO.</th>
                <th class="text-center">类型</th>
                <th class="text-center">合同编号</th>
                <th class="text-center" style="min-width: 240px;width: 240px">合同主题</th>
                
                <th  class="text-center">状态</th>
                <th  class="text-center">申请人</th>
                <th  class="text-center">申请时间</th>
                <th  class="text-center">操作</th>
            </tr>
            {volist name="apply" id="vo"}
                <tr class="text-center">
                    <td class="text-center">{$i}</td>
                     <td class="text-center">合同申请</td>
                    <td class="text-center"><a class="addnew num2 ObjectNum" title="合同详情" href='{:url("detail")}?hid={$vo.id}'>{$vo.htbh}</a></td>
                    <td class="text-center" style="min-width: 240px;width: 240px">{$vo.jxs_name}-{$vo.htmc_nf}年合同</td>
                    <td class="text-center">{$vo.zhuangtai}</td>
                    <td class="text-center">{$vo.em_name}</td>
                    <td class="text-center">{$vo.ctime}</td>
                    <td class="text-center">
                       
                        <a href="{:url('Workflowdb/workflowchart',['id'=>$vo.myId])}" class="J_menuItem" title="查看流程图">查看流程图</a>
                       
                    </td>
                </tr>
            {/volist}
        </table>
          <h5 class="text-center" id="pagesc" style="font-size: 16px;font-weight: 500">
            <script>
                            $(function(){
                                pageSC("pagesc",{$sum},{$page},{$maxpage})
                            })
                        </script>每页显示
           <select id="pagesize">
                        <option value='10' {if condition="$list eq 10"}selected{/if}>10条</option>
                        <option value='20'{if condition="$list eq 20"}selected{/if}>20条</option>
                        <option value='40'{if condition="$list eq 40"}selected{/if}>40条</option>

            </select>
        </h5>
    </form>
</div>
<!-- 全局js -->
{include file="Public/footer"}

<!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
<script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<!--统计代码，可删除-->
<script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
  <script src="__STATIC__/layout/js/contabs_sub.js"></script>
   <script>
            //翻页
      
        $("#check").click(function(){
              $("#page-go").val(1);
              $(".formpage").submit();
        })
        $("#clear_check").click(function(){
            $("input[type='text']").val("");
            $("select").val(0);
            $("#page-go").val(1);
            $(".formpage").submit();
        })
   $(".num").blur(function(){
    //alert(1);
        if(isNaN(parseFloat($(this).val()))){
            $(this).val("");
        }else{
            $(this).val(parseFloat($(this).val()));
        }
   })
    $(".addnew").click(menuItem);
    function menuItem() {
    // 获取标识数据
    var dataUrl = $(this).attr('href'),
        dataIndex = $(this).data('index'),
        menuName = $.trim($(this).attr("title")),
        flag = true;
    if (dataUrl == undefined || $.trim(dataUrl).length == 0)return false;

    // 选项卡菜单已存在
    top.$('.J_menuTab').each(function () {
        if ($(this).data('id') == dataUrl) {
            if (!$(this).hasClass('active')) {
                $(this).addClass('active').siblings('.J_menuTab').removeClass('active');
                scrollToTab(this);
                // 显示tab对应的内容区
                top.$('.J_mainContent .J_iframe').each(function () {
                    if (top.$(this).data('id') == dataUrl) {
                        top.$(this).show().siblings('.J_iframe').hide();
                        return false;
                    }
                });
            }
            flag = false;
            return false;
        }
    });

    // 选项卡菜单不存在
    if (flag) {
        var str = '<a href="javascript:;" class="active J_menuTab" data-id="' + dataUrl + '">' + menuName + ' <i class="fa fa-times-circle"></i></a>';
        top.$('.J_menuTab').removeClass('active');

        // 添加选项卡对应的iframe
        var str1 = '<iframe class="J_iframe" name="iframe' + dataIndex + '" width="100%" height="100%" src="' + dataUrl + '" frameborder="0" data-id="' + dataUrl + '" seamless></iframe>';
        top.$('.J_mainContent').find('iframe.J_iframe').hide().parents('.J_mainContent').append(str1);

        //显示loading提示
//            var loading = layer.load();
//
//            $('.J_mainContent iframe:visible').load(function () {
//                //iframe加载完成后隐藏loading提示
//                layer.close(loading);
//            });
        // 添加选项卡
        top.$('.J_menuTabs .page-tabs-content').append(str);
        scrollToTab(top.$('.J_menuTab.active'));
    }
    return false;
}
//滚动到指定选项卡
function scrollToTab(element) {
    var marginLeftVal = calSumWidth(top.$(element).prevAll()), marginRightVal = calSumWidth(top.$(element).nextAll());
    // 可视区域非tab宽度
    var tabOuterWidth = calSumWidth(top.$(".content-tabs").children().not(".J_menuTabs"));
    //可视区域tab宽度
    var visibleWidth = top.$(".content-tabs").outerWidth(true) - tabOuterWidth;
    //实际滚动宽度
    var scrollVal = 0;
    if (top.$(".page-tabs-content").outerWidth() < visibleWidth) {
        scrollVal = 0;
    } else if (marginRightVal <= (visibleWidth - top.$(element).outerWidth(true) - top.$(element).next().outerWidth(true))) {
        if ((visibleWidth - top.$(element).next().outerWidth(true)) > marginRightVal) {
            scrollVal = marginLeftVal;
            var tabElement = element;
            while ((scrollVal - top.$(tabElement).outerWidth()) > (top.$(".page-tabs-content").outerWidth() - visibleWidth)) {
                scrollVal -= top.$(tabElement).prev().outerWidth();
                tabElement = top.$(tabElement).prev();
            }
        }
    } else if (marginLeftVal > (visibleWidth - top.$(element).outerWidth(true) - top.$(element).prev().outerWidth(true))) {
        scrollVal = marginLeftVal - top.$(element).prev().outerWidth(true);
    }
    top.$('.page-tabs-content').animate({
        marginLeft: 0 - scrollVal + 'px'
    }, "fast");
}
//计算元素集合的总宽度
function calSumWidth(elements) {
    var width = 0;
    top.$(elements).each(function () {
        width += top.$(this).outerWidth(true);
    });
    return width;
}


    </script>
<script>
//删除
function shanchu(id){
     swal({
      title: "您确定嘛?",
      text: "删除后将不能恢复，请确认",
      type: "warning",
      showCancelButton: true,
      confirmButtonColor: "#DD6B55",
      confirmButtonText: "确定",
      cancelButtonText: "取消",
      closeOnConfirm: false
    },
    function(){
      $.post("{:url('shanchu')}",{id:id},function(re){
            if(re==1){

                        swal({
                                title: "完成",
                                text: "操作已成功",
                                type: "success"
                                },function(){
                                  location.href="{:url('index')}"
                                  //
                                });
               
                
            }else{
                 swal({
                                title: "错误",
                                text: "系统繁忙请稍后再试",
                                type: "warning"
                                });
            }
      })
    });
}
//提交工作流
function tijiao(id){
    swal({
      title: "您确定嘛?",
      text: "提交后将不能撤销，请核对完相关内容",
      type: "warning",
      showCancelButton: true,
      confirmButtonColor: "#DD6B55",
      confirmButtonText: "确定",
      cancelButtonText: "取消",
      closeOnConfirm: false
    },
    function(){
      $.post("{:url('tijiao')}",{id:id},function(re){
            if(re==1){

                        swal({
                                title: "完成",
                                text: "操作已成功",
                                type: "success"
                                },function(){
                                   document.getElementById("f1").submit();
                                  //
                                });
               
                
            }else{
                 swal({
                                title: "错误",
                                text: "系统繁忙请稍后再试",
                                type: "warning"
                                });
            }
      })
    });
}
    //日期范围限制
    var start = {
        elem: '#start',
        format: 'YYYY-MM-DD',
       // min: laydate.now(), //设定最小日期为当前日期
        max: '2099-06-16 23:59:59', //最大日期
        istime: true,
        istoday: false,
        choose: function (datas) {
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    };
    var end = {
        elem: '#end',
        format: 'YYYY-MM-DD',
        //min: laydate.now(),
        max: '2099-06-16 23:59:59',
        istime: true,
        istoday: false,
        choose: function (datas) {
            start.max = datas; //结束日选好后，重置开始日的最大日期
        }
    };
    var start1 = {
        elem: '#start1',
        format: 'YYYY-MM-DD',
      //  min: laydate.now(), //设定最小日期为当前日期
        max: '2099-06-16 23:59:59', //最大日期
        istime: true,
        istoday: false,
        choose: function (datas) {
            end1.min = datas; //开始日选好后，重置结束日的最小日期
            end1.start1 = datas //将结束日的初始值设定为开始日
        }
    };
    var end1 = {
        elem: '#end1',
        format: 'YYYY-MM-DD',
    //    min: laydate.now(),
        max: '2099-06-16 23:59:59',
        istime: true,
        istoday: false,
        choose: function (datas) {
            start1.max = datas; //结束日选好后，重置开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);
    laydate(start1);
    laydate(end1);
</script>
</body>

</html>
